package com.ruoyi.delivery.controller;

import com.ruoyi.delivery.domain.DelTransportDetail;
import com.ruoyi.delivery.service.IDelTransportDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/delivery/transportDetail")
public class DelTransportDetailController {

    @Autowired
    private IDelTransportDetailService transportDetailService;

    /**
     * 根据 trackingNumber 获取所有运单明细
     * @param trackingNumber 运单号
     * @return 运单明细列表
     */
    @RequestMapping
    public List<DelTransportDetail> getDetailsByTrackingNumber(String trackingNumber) {
        return transportDetailService.getDetailsByTrackingNumber(trackingNumber);
    }

    @RequestMapping("/filter/{trackingNumber}")
    public List<DelTransportDetail> searchTransportDetails(
            String productName,
            String orderNumber,
            String productBatch, @PathVariable String trackingNumber) {
        return transportDetailService.searchTransportDetails(trackingNumber,productName, orderNumber, productBatch);
    }

    @RequestMapping("/order/{orderNumber}")
    public List<DelTransportDetail> getDetailsByOrderNumber(@PathVariable("orderNumber") String orderNumber) {
        return transportDetailService.getDetailsByOrderNumber(orderNumber);
    }


}
